package com.boot.security.controller;

import com.boot.persistence.controller.ControllerImpl;
import com.boot.persistence.controller.IControllerMapping;
import com.boot.security.model.po.User;
import com.boot.security.service.database.UserService;
import com.boot.web.http.HttpModel;
import com.boot.web.util.HttpResponseUtil;
import io.swagger.annotations.Api;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Validator;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description implements {@link IControllerMapping}
 * @date 2019/11/19 18:46
 **/
@RestController
@RequestMapping("/user")
@Api("用户接口")
public class UserController extends ControllerImpl<Long, User, UserService> {

    public UserController(UserService service, Validator validator) {
        super(service, validator);
    }

    @PostMapping("/id/{id}")
    public ResponseEntity<HttpModel<Object>> resetPassword(@PathVariable Long id) {
        if (service.resetPassword(id)) {
            return HttpResponseUtil.OK("重置密码成功");
        }
        return HttpResponseUtil.badRequest("重置密码失败");
    }
}
